home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / env.zip / ENV.DOC < prev    next >
Text File  |  1988-06-09  |  5KB  |  132 lines

  1. ENV.DOC
  2.  
  3. SUMMARY
  4. =======
  5. The file ENV.COM was written for use within .BAT files under MSDOS 3.20 
  6. on an XT clone. It has three uses: 
  7.  
  8.    a) ENV PAD   fills the unused space in the current environment 
  9.                 gracefully in 14-byte blocks with variables
  10.                     ENV01=abcdefg
  11.                     ENV02=abcdefg
  12.                     ENV03=abcdefg
  13.                       :  :   :
  14.    b) ENV UNPAD removes ENV01, ENV02, ... from the current environment, 
  15.                 (to which they have normally been carried by an 
  16.                  application call)
  17.    c) ENV <anything else> displays a brief syntax reminder.
  18.              
  19. The parameters are case-insensitive.
  20.  
  21. ENV.COM works by tracing back through memory via particular bytes in the 
  22. chain of PSP's and the environments that precede them until it finds an 
  23. environment which is the one that will be carried upwards in an 
  24. application call. 
  25.                  
  26. ENV.COM has not been tested with other versions of MSDOS. Its use with 
  27. them depends entirely on whether Microsoft has maintained a consistent 
  28. definition of the use of bytes in PSP's and environments. 
  29.  
  30. USE OF ENV.COM
  31. ==============
  32. When an application is called, MSDOS carries upwards environments which 
  33. only have just enough segments to hold the variables which have been set 
  34. (and possibly a copy of the string calling the application). 
  35.  
  36. Short of re-writing the ***logic*** of MSDOS, the only way to carry 
  37. upwards an environment of the size set in CONFIG.SYS by the /e: switch 
  38. of 
  39.                    SHELL=<drive><path>COMMAND.COM /e:nnnn
  40. seems to be to stuff it full!  That is what ENV.COM does.
  41.  
  42. Unless your current environment is already full, you can see the effect 
  43. of ENV.COM very easily in direct mode by typing 
  44.                    SET
  45.                    ENV PAD
  46.                    SET
  47.                    ENV UNPAD
  48.                    SET .                              
  49. In effect it is simply an automated version of
  50.                    SET ENV00=abcdef
  51.                     :    :      :
  52. In order to do its job it has to trace back illegitimately far through 
  53. memory to find the environment that will be carried upwards by an 
  54. application. It then directly edits that environment segment. 
  55.  
  56. I use ENV.COM in all my batch files just before and just after the main 
  57. application calls. The following three annotated fragments give the 
  58. general idea. In the fragments I use < > to indicate deletions of major 
  59. blocks of commands whose details are not relevant to this note, and 
  60. leading colons (:) for normal MSDOS comment lines. 
  61.  
  62.   1. AUTOEXEC.BAT
  63.  
  64.      <Early parts of the start-up routine>
  65.       PATH C:\DOS;C:\DOS\OWNTOOLS;C:\DOS\TOOLS;C:\BIN;
  66.      :c:\bin contains all the batch files for calling applications
  67.       ENV PAD 
  68.      <Calls of major TSR applications (for example PCTOOLS)>
  69.       ENV UNPAD
  70.      <Rest of autoexec.bat>
  71.  
  72.      It is some months since I installed this and at the time of 
  73.      preparing this note I can't remember whether this was in response 
  74.      to real trauma or whether it was a just-to-be-safe detail in 
  75.      installing the latest PCTOOLS! 
  76.  
  77.   2. ANAGRAM.BAT - for WORD's anagram finder: this is an application 
  78.      from which further applications cannot be called. It need therefore 
  79.      only make room for itself if it is offered a fully-stuffed 
  80.      environment. 
  81.  
  82.      <cosmetic headings>
  83.      ENV UNPAD
  84.      PATH=C:\WORD;
  85.      APPEND=C:\WORD
  86.      IF     %1@==@ C:\WORD\ANAGRAM
  87.      IF NOT %1@==@ C:\WORD\ANAGRAM %1
  88.  
  89.  
  90.   3. KERMIT.BAT,  above which further applications can be, and often 
  91.      are, called, and which therefore needs to pass upward a big enough 
  92.      environment. 
  93.  
  94.      There is an additional problem to be dealt with. Microsoft left 
  95.      APPEND out of the environment structure. So although details of 
  96.      paths set by PATH are automatically restored after an application 
  97.      call, the paths set by APPEND are not restored unless *I* do 
  98.      something about them. So I find that every nestable application 
  99.      needs: 
  100.  
  101.           to record its append-state and tell its children, 
  102.           to preserve the append-state of its own parent and restore it. 
  103.  
  104.      In the annotations I pretend that KERMIT.BAT and KERMIT.EXE can 
  105.      speak for themselves 
  106.  
  107.      <cosmetic header>
  108.     :release the space we've been given
  109.      ENV UNPAD
  110.     :preserve a record of what our parent needs us to do for it
  111.      SET OLDAPPEND=%APPEND%
  112.     :preserve a record of what we will need any children to do just 
  113.     :  before they hand back to us
  114.      SET APPEND=APPEND C:\KERMIT;C:\BIN;
  115.     :do it for ourselves while we can
  116.      %APPEND%
  117.      PATH=C:\BIN;C:\KERMIT;C:\DOS;C:\DOS\TOOLS;C:\DOS\OWNTOOLS;C:\;
  118.     :stuff environment space in case we have children
  119.      ENV PAD                                      
  120.     :enter the main application
  121.      C:\KERMIT\KERMIT %1 %2 %3 %4
  122.     :having returned from the application, make room to tidy up
  123.      ENV UNPAD
  124.     :restore text file paths for our parent (command paths will be 
  125.     :  automatically restored by MSDOS when this batch file finishes)
  126.      %OLDAPPEND%
  127.     :End of KERMIT.BAT (and therefore hand back to parent)
  128.  
  129. --------------
  130. End of ENV.DOC
  131.  
  132.